package edu.zut.cs.software.perfect.attendance.service.impl;

import java.util.List;
import java.util.Optional;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import edu.zut.cs.software.perfect.attendance.dao.CourseAttendanceDao;
import edu.zut.cs.software.perfect.attendance.domain.CourseAttendance;
import edu.zut.cs.software.perfect.attendance.service.CourseAttendanceManager;
import edu.zut.cs.software.perfect.base.service.impl.GenericManagerImpl;
/**
 * 
 * @Title: CourseAttendanceManagerImpl
 * @Description: TODO
 * @author: lipengde
 * @date 2020年5月25日 下午7:18:39
 */
@Service("courseAttendanceManager")
@Transactional
public class CourseAttendanceManagerImpl extends GenericManagerImpl<Long, CourseAttendance>
		implements CourseAttendanceManager {

	/*
	 * @Override
	public CourseAttendance echo(CourseAttendance courseAttendance) {
		courseAttendance.setStudentName("QingShiHuang");
		courseAttendance.setStudentId("201808064523");
		return courseAttendance;
	}
	*/
	
	CourseAttendanceDao courseAttendanceDao;
	
	@Autowired
	public void setCourseAttendanceDao(CourseAttendanceDao courseAttendanceDao) {
		this.courseAttendanceDao = courseAttendanceDao;
		this.dao=this.courseAttendanceDao;
	}

	@Override
	public List<CourseAttendance> findAll(){
		return (List<CourseAttendance>)this.dao.findAll();
	}
	
	@Override
	public Optional<CourseAttendance> findByCourseId(Long courseId) {
		// TODO Auto-generated method stub
		Optional<CourseAttendance> result = this.dao.findById(courseId);
		return result;
	}

	@Override
	public Boolean deleteById(Long courseId) {
		// TODO Auto-generated method stub
		//为空返回Optional.empty()
				Optional<CourseAttendance> courseattendance = this.dao.findById(courseId);
				if(courseattendance.equals(Optional.empty())) {
					return false;
				}else {
					this.dao.delete(courseattendance.get());
					return true;
				}
	}

//	@Override
//	public List<CourseAttendance> findByFullname(String string) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	@Override
//	public List<CourseAttendance> findByCourseName(String courseId) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	@Override
//	public Iterable<CourseAttendance> findAll() {
//		// TODO Auto-generated method stub
//		return super.findAll();
//	}

}
